#include "includes.h"
#include "main.h"
	
OS_STK TestTaskStk[200];

volatile timer804_t* const tregs = (timer804_t*)TIMER_BASE;

void timer_init(void){
	tregs->timers[0].BGLoad = 0xf000;
	tregs->timers[0].Control |= SP804_TIMER_PERIODIC; 
	tregs->timers[0].Value = 0;
	tregs->timers[0].Control |= SP804_TIMER_ENABLE;
}

void TestTask(void *pdata)
{
	pdata = pdata;
	timer_init();
	GIC_Enable();
	GIC_EnableIRQ(TIM01INT_IRQn);                
	while(1) {
		display("qemu-system-arm: TestTask: Hello Open World\n"); 
		OSTimeDly(1);
	}
}

int armmain()
{
	display("qemu-system-arm: Hello Open World\n"); 
	OSInit();
	display("qemu-system-arm: OSInit OK!\n"); 
	OSTaskCreate(TestTask, (void*)0, &TestTaskStk[199], 0);
	OSStart();
}


